package haonan3344.localbbs.db;

import haonan3344.localbbs.conf.Settings;

import org.apache.commons.dbcp.BasicDataSource;

public class LbDataSource {
	static LbDataSource _instance=null;
	private BasicDataSource ds;
	
	
	
	public LbDataSource(){
		
	}
	
	private void init(){
		ds = new BasicDataSource();
        ds.setDriverClassName(Settings.getDatabaseSettings().getConnDriver());
        ds.setUsername(Settings.getDatabaseSettings().getConnUsername());
        ds.setPassword(Settings.getDatabaseSettings().getConnPassword());
        ds.setUrl(Settings.getDatabaseSettings().getConnStr());
	}
	
	public static LbDataSource instance(){
		if(_instance ==null){
			_instance = new LbDataSource();
			_instance.init();
		}
		
		return _instance;
	}
	
	public BasicDataSource getDataSource(){
		return ds;
	}
	
}
